<?php 
	$message = $this->message;
?>

<section class="grid_12" style="width: 60%;margin-left: 20%;">
	<div class="block-border" style="margin-bottom: 20px;">
	       <form class="block-content form" id="edit_form" method="post" action="">
				<?php echo $this->formHidden("edit_id", $this->edit_id)?>
				<h1>会議室情報</h1>
				
				<fieldset>
					<legend>会議室情報</legend>

					<!-- Message display -->
					<?php if($message):?>
					<ul class="message error no-margin">
						<li><?php echo $message?></li>
					</ul>
					<?php endif;?>

					<p class="inline-label">
						<label for="code">コード</label>
						<?php echo $this->formText("code", $this->code);?>
					</p>
					
					<p class="inline-label">
						<label for="type">タイプ</label>
						<?php echo $this->formSelect("type", $this->type, NULL, $this->room_type_list)?>
					</p>
					
					<p class="inline-label">
						<label for="number_seat">席の数</label>
						<?php echo $this->formSelect("number_seat", $this->number_seat, NULL, $this->number_seat_list)?>
					</p>
					
					<p class="inline-label">
						<label for="rent_price">単価</label>
						<?php echo $this->formText("rent_price", $this->rent_price, array("class"=>'with-tip', 'title'=>'VND/30分'))?>
					</p>
					
					<p class="inline-label">
						<label for="description">概要</label>
						<?php echo $this->formTextarea("description", $this->description, array('rows'=>3, 'cols'=>50));?>
					</p>
					
				</fieldset>

				<fieldset class="grey-bg no-margin">
					<p>
						<button type="submit">更新</button>
						<button type="button" id="cancel-btn">キャンセル</button>
					</p>
				</fieldset>
				
			</form>
		</div>
</section>

<!-- Table script -->
<script type="text/javascript">
	$(document).ready(function(){
		$("#cancel-btn").click(function(){
			window.location = "/admin/room/index";
		});
		
		$("#edit_form").validate({
	 		rules: {
				code: {
	 				required: true
	 			},
	 			
	 			rent_price: {
					required: true,
					number: true,
					min: 1
				}
			},

			messages: {
				code: {
					required: "このフィールドは必須です。"
				},

				rent_price: {
					required: "このフィールドは必須です。",
					number: "有効な番号を入力してください。",
					min: "0より大きい値を入力してください。"
				}
			}
		});
	});	
</script>
